package com.stream;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.stream.Collectors;

public class Test02 {
    public static void main(String[] args) {

        List<String> list = Arrays.asList("a", "b", "c", "d", "e");
        list.stream().forEach(item -> System.out.println(item));

        HashMap<String, Integer> hashMap = new HashMap<>();
        hashMap.put("aaa", 111);
        hashMap.put("bbb", 222);
        hashMap.put("ccc", 333);
        hashMap.put("ddd", 444);

        // hashMap.keySet().stream().forEach(item -> System.out.println(item));

        List<String> stringList = Arrays.asList("张无忌", "周芷若", "赵敏", "张强", "张三丰", "张翠山", "张良", "王二麻子", "谢广坤");
        List<String> list1 = stringList.stream().filter(item -> item.startsWith("张")).filter(item -> item.length() == 2).collect(Collectors.toList());
        for (String s : list1) {
            System.out.println("111" + s);
        }


        List<String> list2 = stringList.stream().limit(3).collect(Collectors.toList());

        for (String s : list2) {
            System.out.println("222" + s);
        }


        List<String> list3 = stringList.stream().skip(3).collect(Collectors.toList());

        for (String s : list3) {
            System.out.println("333" + s);
        }
    }
}
